﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Npgsql;


namespace br.com.SistemaChamados
{
    public class Mapped
    {
        public static IDbConnection Connection()
        {
            NpgsqlConnection objConexao = new NpgsqlConnection(ConfigurationManager.AppSettings["stringConnection"]);
            objConexao.Open();
            return objConexao;

        }

        public static IDbCommand Command(string query, IDbConnection objConexao)
        {
            IDbCommand command = objConexao.CreateCommand();
            command.CommandText = query;
            return command;
        }

        public static IDbDataParameter Parameter(string nomeParameter, object valor)
        {
            return new NpgsqlParameter(nomeParameter, valor);
        }

        public static IDbDataAdapter Adapter(IDbCommand command)
        {
            IDbDataAdapter adap = new NpgsqlDataAdapter();
            adap.SelectCommand = command;
            return adap;
        }
    }
}
